package com.hyx.api.controller.applet_shop;

import com.hyx.api.domain.bo.ModelBo;
import com.hyx.api.domain.bo.VerifyModelOptionBo;
import com.hyx.api.config.ApiPrefixRestController;
import com.hyx.api.service.IAppShopService;
import com.hyx.api.service.IModelService;
import com.ruoyi.common.core.domain.AjaxResult;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@RequiredArgsConstructor
@ApiPrefixRestController
@RequestMapping("/appShopApi/model")
public class AppShopModelController {

    private final IAppShopService appShopService;

    private final IModelService modelService;

    /**
     * 获取所有添加的类型列表
     */
    @GetMapping("/queryTypeList")
    public AjaxResult queryTypeList() {
        return appShopService.queryTypeList();
    }

    /**
     * 根据字典类型获取字典值
     */
    @GetMapping("/queryTypeDataList")
    public AjaxResult queryTypeDataList(@RequestParam("dictType") String dictType) {
        return appShopService.queryTypeDataList(dictType);
    }

    /**
     * 获取机型列表
     */
    @GetMapping("/queryModelList")
    public AjaxResult queryModelList(ModelBo bo) {
        bo.setStatus(1);
        return AjaxResult.success(modelService.selectModelList(bo));
    }

    /**
     * 新增验机选项（包含验机成色）
     */
    @PostMapping("/insertVerifyModelOption")
    public AjaxResult insertVerifyModelOption(@Validated @RequestBody VerifyModelOptionBo bo) {
        appShopService.insertVerifyModelOption(bo);
        return AjaxResult.success();
    }

    /**
     * 根据机型获取验机选项列表
     */
    @PostMapping("/queryVerifyOptions")
    public AjaxResult queryVerifyOptions(@RequestParam("modelTypeId") Integer modelTypeId) {
        return appShopService.queryVerifyOptions(modelTypeId);
    }

    /**
     * 修改验机选项（包含验机成色）
     */
    @PostMapping("updateVerifyModelOption")
    public AjaxResult updateVerifyModelOption(@Validated @RequestBody VerifyModelOptionBo bo) {
        appShopService.updateVerifyModelOption(bo);
        return AjaxResult.success();
    }

    /**
     * 删除验机选项（包含验机成色）
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        appShopService.deleteVerifyModelOptionByIds(ids);
        return AjaxResult.success();
    }

}
